home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / news / grayimag.txt / text0000.txt < prev   
Encoding:
Text File  |  1994-07-04  |  3.9 KB  |  86 lines

  1. This package has just been posted to comp.sources.misc.
  2.  
  3.     grayimage_classlib is a C++ class library to do a generic
  4. processing of grayscale images.  It is one part of my image
  5. compression code I've been messing with for almost 3 years. This part
  6. is general enough to be of some interest to folks at large (I
  7. hope). It lets you do a variety of different operations on images,
  8. rectangular areas, etc: say, add two images, compute their "scalar
  9. product", modify pixel values over the entire image or some
  10. rectangular area of it in a _variety_ of ways, equalize the image
  11. histogram, stuff like that.  One function, shift_clip_add(), does
  12. actually the filtration (convolution). Morphological filtration is
  13. implemented as well. I tried to make the code as optimal as I could
  14. think of (without getting into assembly -:). The package can
  15. read/write XWD, Group G TIFF and PGM file formats; actually, the
  16. package understands which file format it's asked to read and selects
  17. the appropriate method automatically.  I demonstrated pieces at Data
  18. Compression Conferences, and some people suggested me submit it into
  19. the public domain.
  20.  
  21.     The file images.dr tells exactly which modules are in the
  22. package and what they are good for. There are several v*.cc files in
  23. the package: these are verification files, you can compile them and
  24. run to make sure everything works as it's supposed to.  The validation
  25. files can also be used as an example as to how to use the package
  26. (because they test, that is, use all the constructions/classes
  27. /functions /methods of the package, and not once 8:)
  28.  
  29.     The package has been compiled with gcc/g++ version 2.2.2 and
  30. later on Sun Sparc/SunOS, HP 9000, Sequent Symmetry/Dynix,
  31. Concurrent/RTU, and with Symantec C++ 6.0.1 (through 7.0.2) on Mac.
  32. The package has been in operation for 2.5 years.
  33.  
  34.     I also have to mention that the image package I'm submitting
  35. is just the very bottom layer of the image and video processing stuff
  36. I've been working on. The bottom layer is meant to give the basic
  37. working environment rather to do something fancy with the image
  38. (though, BTW, function shift_clip_add() makes the convolution in two
  39. stmts; and this lets you do a whole lot of the fancy things in the
  40. digital darkroom). So, there is much more to the story. BTW, it also
  41. means that I'm constantly adding to the package (as I come across a
  42. need for some function, option, etc), so your comments/suggestions
  43. will be highly appreciated.
  44.  
  45.     And now, here's a quick glance at the package capabilities:
  46.  
  47. // Note! This is the *correct* code; Put it within main(){}, and it will
  48. // compile, run and finish without errors
  49.  
  50. // Pixel operations
  51.  
  52. IMAGE im1(256,256,8); IMAGE im2(im1);
  53. im1 = 1; im2 = im1; im1 *= 4;        // Assigning a value to every pixel
  54. assert( im1 == 4 ); assert( im1 >0 );    // Checking up the value of every pixel
  55. im1.invert(); im1.clear(); im2 <<= 2; im1 = 5; 
  56. im1 &= 0xfe;  assert( im1==im2);    // Modifying every pixel
  57. im1.clear(); im1 -= im2; im2 = im1;     // Subtracting two images
  58.                     // Applying *any* function to every
  59. im1.abs(); im2.apply(::abs); assert(im1 == im2); // pixel (abs() in the ex.)
  60. assert( im1 * im1 == norm_2_sqr(im1) );    // Computing the "scalar product"
  61.                     // and image norm
  62.  
  63. // Square and rectangular parts of image
  64.  
  65. im1 = 2*pattern; im2 = pattern;
  66. rowcol rightbottom(im1.q_nrows()-1,im1.q_ncols()-1);
  67. rowcol center(im1.q_nrows()/2,im1.q_ncols()/2);
  68.                     // Modifying pixels only within the
  69.                     // lower left quadrant
  70. im1.rectangle(center,rightbottom) -= 2*pattern;
  71. assert( !(im1 == 2*pattern) && !(im1 != 2*pattern) );
  72.                     // Another way of doing this
  73. im1.shift_clip_add(center,2,im2);  assert(im1 == 2*pattern);
  74.  
  75. // Miscellanea
  76.                     // Note "expanded" file name of the
  77.                     // image
  78. IMAGE raw_image("zcat ../../pictures/lenna.xwd.Z |");
  79. //  IMAGE image(IMAGE::Shrink,raw_image);
  80. IMAGE image = raw_image.square_of(256,rowcol(120,100));
  81. image.write("/tmp/ior","Original image");
  82. image.display("Image to display");
  83.  
  84.  
  85.  
  86.